var DBFactory = require('../db/mysql_db');
var adminDao = module.exports;

adminDao.login = function(data, cb){
    if(!data) return cb(new Error(500));
    var sql = 'select * from admin where account = ? ';
    DBFactory.executeSql(sql, [data.account], 'login', function(err, result) {
        if(err) return cb(err);
        if(result && result[0]) {
            if(result[0]['password'] == data.password) return cb(null,result[0]);
            cb('密码或账号不正确');
        } else {
            cb('密码或账号不正确');
        }
    });
}